﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dbPoll_Application.ViewModels.PollReportViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Reports
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="pageHeadingContainer"><h2 class="pageHeading">Reports</h2></div>
    <div id="contentContainer">
    <p><%= Html.ActionLink("Reports > ", "Index", "SystemReport", null, new { @class = "breadcrumb" })%>Session History Report</p>
    
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript"> 
     
    onload = function(){
        <% 
            int j = 0;
            foreach (var poll in Model.allPolls)
            {
        %>
            var geocoder;
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(<%=poll.latitude%>, <%=poll.longitude%>);
            
           geocoder.geocode({ 'latLng': latlng }, function(results, status) {
                        document.getElementById('location<%=poll.pollID%>').innerHTML = results[1].formatted_address;
                    });                   
            <%
                j++;
                }
            %>
            
        }   
    </script>   

        <table class="reports">
        <tr class="reports">
            <th class="reports">Poll #</th>
            <th class="reports">Poll Name</th>
            <th class="reports">Attendance</th>
            <th class="reports">Location</th>
            <th class="reports">Opening Time</th>
            <th class="reports">Closing Time</th>
            <th class="reports">Poll Master</th>
            <th class="reports">Poll Creator</th> 
        </tr>
       
        <% 
            foreach (var poll in Model.allPolls)
            {
        %>
       
        <tr class="reports">
            <td class="reports"><%=poll.pollID%></td>
            <td class="reports"><%=poll.name %></td>
            <td class="reports"><%=Model.attendanceList[poll]%></td>
            <td class="reports" id="location<%=poll.pollID%>"></td>
            <td class="reports"><%=poll.pollStart%></td>
            <td class="reports"><%=poll.pollClose%></td>
            <td class="reports">
                <%
                    int i = 0;
                    foreach (var master in poll.pollMasters) 
                    {
                %>
                        <%=poll.pollMasters[i].FirstName%> <%=poll.pollMasters[i].LastName%></br>
                <%
                    i++;
                    }
                %>
            </td>
            <td class="reports">
                <%
                    foreach (var creator in Model.creatorList[poll]) 
                    {
                %>
                        <%=creator.FirstName%> <%=creator.LastName%></br>
                <%
                    }
                %> 
            </td>
        </tr>
   
        <%
            }
        %>
   
   </table> 
    </div>
    </div>
   
        
</asp:Content>
